package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.enumclass.CustomerStatus;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;

/**
 * Created by zhangjh on 2016/9/23.
 */
@Entity
@Table(name = "customer")
@DynamicInsert
@DynamicUpdate
public class Customer extends IDEntityMall {

    @Column(columnDefinition = "varchar(255) comment '密码'")
    private String password;
    @Column(columnDefinition = "varchar(255) comment '昵称'")
    private String nickName;
    @Column(columnDefinition = "varchar(255) comment '分享码'")
    private String shareCode;
    @Column(columnDefinition = "varchar(255) comment '状态 NORMAL(\"正常\"), DISABLE(\"停用\")'")
    @Enumerated(EnumType.STRING)
    private CustomerStatus status = CustomerStatus.NORMAL;
    @Column(columnDefinition = "bigint comment '平台ID'")
    private Long mallId;
    @Column(columnDefinition = "varchar(255) comment '联系电话'", unique = true)
    private String mobile;
    @Column(columnDefinition = "varchar(255) comment '绑定微信OpenId'", unique = true)
    private String wechatOpenId;
    @Column(columnDefinition = "varchar(255) comment '绑定微信昵称'")
    private String wechatNickName;
    @Column(columnDefinition = "varchar(255) comment '微信用户头像'")
    private String wechatHeadimgurl;
    @Column(columnDefinition = "varchar(255) comment '绑定微信unionId'")
    private String wechatUnionId;
    @Column(columnDefinition = "varchar(255) comment '绑定手机协议签订 NO(\"未签订\"), YES(\"已签订\")'")
    @Enumerated(EnumType.STRING)
    private Whether protocol = Whether.NO;
    @Column(columnDefinition = "bigint comment '用户资金账户ID'")
    private Long customerFundId;

    @Column(columnDefinition = "varchar(255) comment '性别'")
    private String sex ;

    @Column(columnDefinition = "varchar(255) comment '语言'")
    private String language;

    @Column(columnDefinition = "varchar(255) comment '城市'")
    private String city;

    @Column(columnDefinition = "varchar(255) comment '省份'")
    private String province;

    @Column(columnDefinition = "varchar(255) comment '国家'")
    private String country;

    @Column(columnDefinition = "varchar(255) comment '绑定微信小程序OpenId'", unique = true)
    private String wxappOpenId;

    // 微信客户登录的cookie
    public static final String REDIS_CUSTOMER_USER_TOKEN_PREFIX = "customer_user_token_";


    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getNickName() {
        return nickName;

    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getShareCode() {
        return shareCode;
    }

    public void setShareCode(String shareCode) {
        this.shareCode = shareCode;
    }

    public CustomerStatus getStatus() {
        return status;
    }

    public void setStatus(CustomerStatus status) {
        this.status = status;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public String getWechatOpenId() {
        return wechatOpenId;
    }

    public void setWechatOpenId(String wechatOpenId) {
        this.wechatOpenId = wechatOpenId;
    }

    public String getWechatNickName() {
        return wechatNickName;
    }

    public void setWechatNickName(String wechatNickName) {
        this.wechatNickName = wechatNickName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getWechatUnionId() {
        return wechatUnionId;
    }

    public void setWechatUnionId(String wechatUnionId) {
        this.wechatUnionId = wechatUnionId;
    }

    public String getWechatHeadimgurl() {
        return wechatHeadimgurl;
    }

    public void setWechatHeadimgurl(String wechatHeadimgurl) {
        this.wechatHeadimgurl = wechatHeadimgurl;
    }

    public Whether getProtocol() {
        return protocol;
    }

    public void setProtocol(Whether protocol) {
        this.protocol = protocol;
    }

    public Long getCustomerFundId() {
        return customerFundId;
    }

    public void setCustomerFundId(Long customerFundId) {
        this.customerFundId = customerFundId;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public static String getRedisCustomerUserTokenPrefix() {
        return REDIS_CUSTOMER_USER_TOKEN_PREFIX;
    }

    public String getWxappOpenId() {
        return wxappOpenId;
    }

    public void setWxappOpenId(String wxappOpenId) {
        this.wxappOpenId = wxappOpenId;
    }

    @Override
    public String toString() {
        return "Customer{" +
                ", id=" + id +
                ", nickName='" + nickName + '\'' +
                ", dateCreated=" + dateCreated +
                ", shareCode='" + shareCode + '\'' +
                ", lastUpdated=" + lastUpdated +
                ", status=" + status +
                ", mallId=" + mallId +
                ", isDelete=" + isDelete +
                ", version=" + version +
                ", mobile='" + mobile + '\'' +
                ", wechatOpenId='" + wechatOpenId + '\'' +
                ", wechatNickName='" + wechatNickName + '\'' +
                ", wechatHeadimgurl='" + wechatHeadimgurl + '\'' +
                ", wechatUnionId='" + wechatUnionId + '\'' +
                ", protocol=" + protocol +
                ", customerFundId=" + customerFundId +
                ", sex='" + sex + '\'' +
                ", language='" + language + '\'' +
                ", city='" + city + '\'' +
                ", province='" + province + '\'' +
                ", country='" + country + '\'' +
                ", wxappOpenId='" + wxappOpenId + '\'' +
                '}';
    }
}
